package com.example.server.Contr;

import com.example.server.Service.ReviewService;
import com.example.server.entity.Favorite;
import com.example.server.entity.Love;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/review")
public class LTcount {
    @Autowired
    ReviewService reviewService;
    @RequestMapping("/lovebyid")//查询该地点有多少点赞
    public int select(@RequestParam("id") int placeid){ //使用地点id查询点赞数量
        System.out.println(placeid);
        return reviewService.getlove(placeid);
    }
    //查询该地点是否已经点赞。
    @RequestMapping("/lovebyplace")
    public int select(@RequestParam("placeid") String lo_id,@RequestParam("uid") String uid){
        return reviewService.getlovebylocationpersonid(lo_id,uid);
    }
    //查询该地点是否已经收藏
    @RequestMapping("/favrbyplace")
    public int selectfar(@RequestParam("placeid") String loid,@RequestParam("uid") String uid){
        return reviewService.getfarid(loid,uid);
    }
    //增加点赞
    @RequestMapping("/addlove")
    public boolean addlove(@RequestParam("lid") String lid,@RequestParam("uid") String uid){
        System.out.println("正在添加"+lid+uid);
        return reviewService.addlove(lid,uid);
    }//增加收藏
    @RequestMapping("/addfar")
    public boolean addfar(@RequestParam("lid") String lid,@RequestParam("uid") String uid){
        System.out.println("正在添加"+lid+uid);
        return reviewService.addfar(lid,uid);
    }
    //删除点赞
    @RequestMapping("/deletelove")
    public boolean dellove(@RequestParam("lid") String lid,@RequestParam("uid") String uid){
        System.out.println("正在删除"+lid+uid);
        return reviewService.dellove(lid,uid);
    }
    //删除点赞
    @RequestMapping("/deletefar")
    public boolean delfar(@RequestParam("lid") String lid,@RequestParam("uid") String uid){
        System.out.println("正在删除"+lid+uid);
        return reviewService.delfar(lid,uid);
    }
}
